<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>帖子列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="icon" th:href="@{/读书1.jpg}" type="image/jpg" >
    <link rel="stylesheet" href="../static/layui-v2.5.7/layui/css/layui.css" th:href="@{/layui-v2.5.7/layui/css/layui.css}">
    <!--  -->
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="../static/layui-v2.5.7/layui/layui.js" th:src="@{/layui-v2.5.7/layui/layui.js}"></script>
    <!--  -->
</head>

<style>

    body{
        background-color: rgb(246,246,246);
        min-width: 1450px;
    }

    .head{
         position: fixed;
         width:100%;
         top:0;
         z-index:1;
    }

    .head_div1{
        width:355px;
        height: 30px;
        display: inline-block;
        /* border: 1px solid red; */
        float: right;
        margin: 15px 15px 0px 0px;
        background-color:rgb(57,61,73);
    }

    .head_div1_input1{
        height: 30px;
        width: 300px;
        border-radius: 5px 5px 5px 5px;
        border: none;
        background-color:rgb(232, 232, 232);
        float: left;
    }


    .head_div1_button{
        height: 30px;
        width: 50px;
        border-radius: 5px 5px 5px 5px;
        background-color:rgb(57,61,73);
        border: 1px solid white;
        //font-family: '楷体';
        font-size: 15px;
        line-height: 30px;
        color: white;
        float: right;
    }

    .head_div2{
        float: right;
        display: inline-block;
        margin-right: 15px;
    }

    .head a {
        //color: black !important;
    }

    .button{
        background-color: white;
        /* 这个白边不能去 */
        //border: 1px solid red;
        margin: 75px auto 0px;
        width: 85%;
        height:52px
    }

    #button{
        float:right;
        margin-right:30px;
        margin-top:15px;
    }

    .div_body{
        background-color: white;
        /* 这个白边不能去 */
        border: 1px solid white;
        margin:auto;
        width: 85%;
        padding-bottom:20px;
        min-height:469px;
    }
   /*  */

   .div_body_div1{
        border-top:1px solid rgb(222,226,230);
        border-bottom:1px solid rgb(222,226,230);
        width:95%;
        height:100px;
        margin: 20px auto 0px;
    }

    .div_body_div1_div1{
        //border:1px solid red;
        width:60px;
        height:60px;
        float:left;
        border-radius:30px;
        margin-top:10px;
    }

    .div_body_div1_div1>img{
        //border:1px solid red;
        width:60px;
        height:60px;
        float:left;
        border-radius:30px;
    }

    .div_body_div1_div2{
        //border:1px solid red;
        width:93%;
        height:50px;
        float:left;
        line-height:50px;
        color: #007bff;
        font-size:16px;
        margin-left:15px;
    }

    .div_body_div1_div3{
        //border:1px solid red;
        width:93%;
        height:50px;
        float:left;
        margin-left:15px;
        line-height:50px;
    }

    .div_body_div1_div3_div1{
        //border:1px solid red;
        display:inline-block;
        float:left;
        width:400px;
        height:30px;
   }

   .div_body_div1_div3_div1_span1{
        color: rgb(108,117,125);
        font-size: 16px;
        //margin-left:10px;
   }

   .div_body_div1_div3_div1_span2{
        color: rgb(108,117,125);
        font-size: 16px;
        margin-left:10px;
   }

   .div_body_div1_div3_div1_span3{
        color: rgb(108,117,125);
        font-size: 16px;
        margin-left:10px;
        font-weight:700;
   }

   .div_body_div1_div3_div2{
        //border:1px solid red;
        display:inline-block;
        float:right;
        width: 200px;
        height:50px;
        line-height:50px;
   }

   .div_body_div1_div3_div2_span1{
        color: rgb(108,117,125);
        font-size: 16px;
        //margin-left:10px;
   }

   .div_body_div1_div3_div2_span2{
        color: rgb(108,117,125);
        font-size: 16px;
        margin-left:10px;
        font-weight:700;
   }

   /* */
    .div_page{
        background-color: white;
        /*border: 1px solid red;*/
        margin:0px auto 15px;
        width: 85%;
        height:60px
    }

   /*  */
    .div_foot {
        width: 100%;
        //border: 1px red solid;
        height: 100px;
        margin-top:10px;
        background-color: rgb(57,61,73);
    }

    a {
        text-decoration: none;
    }

    .div_foot_div1 {
        /* border: red 1px solid; */
        width: 990px;
        height: 85px;
        display: inline-block;
        position: relative;
        top: 10px;
        left: 240px;
        text-align: center;
        font-size: 12px;
        line-height: 150%;
        font-family: Arial, Verdana, 宋体;
        color: white;
    }

    .div_foot_div1 div {
        margin-top: 10px;
    }

    .div_foot_div1_div1 a {
        margin: 0 10px;
        color:white;
    }

<!--  -->
   .addPost_div1{
        margin: auto;
        width: 95%;
        height:50px;
        //border: 1px red solid;
        margin-top: 20px;
        line-height:50px;
   }

   .addPost_div1_span{
        font-size: 25px;
        font-weight: 700;
        border: 1px solid rgb(221,221,221);
        float:left;
        padding:0px 10px 0px 10px;
   }

   .addPost_div1_input{
        height:50px;
        border: 1px solid rgb(221,221,221);
        float:left;
        width:89.7%;
        font-size:20px;
   }

   .addPost_div2{
        margin: auto;
        width: 95%;
        height:400px;
        //border: 1px red solid;
        margin-top: 20px;
   }

   .addPost_div2_textarea{
        width: 100%;
        height:100%;
        border: 1px rgb(221,221,221) solid;
        resize: none;
        font-size:20px;
   }

   .addPost_div3{
        margin: auto;
        width: 95%;
        height:50px;
        /*border: 1px solid rgb(221,221,221);*/
        margin-top: 20px;
        line-height:50px;
    }

   .addPost_div3_span{
        font-size: 25px;
        font-weight: 700;
        border: 1px solid rgb(221,221,221);
        float:left;
        padding:0px 10px 0px 10px;
    }

   .addPost_div3_select{
        height:51.5px;
        border: 1px solid rgb(221,221,221);
        float:left;
        width:90%;
        font-size:20px;
    }

   .addPost_div5{
        margin: auto;
        width: 95%;
        height:50px;
        /*border: 1px solid rgb(221,221,221);*/
        margin-top: 10px;
   }

   .layui-btn{
        float:right;
        margin-top:6px;
   }

</style>

<body>

<div class="head">
    <ul class="layui-nav">

        <li class="layui-nav-item">
            <a th:href="@{/index}">
                <i class="layui-icon layui-icon-home"></i>
                首页
            </a>
        </li>

        <li class="layui-nav-item ">
            <a th:href="@{/toSystemMessage}">
                <i class="layui-icon layui-icon-notice"></i>
                系统消息
            </a>
        </li>

        <li class="layui-nav-item">
            <a href="">
                <i class="layui-icon layui-icon-read"></i>
                文章类型
            </a>
            <dl class="layui-nav-child">
                <!-- 二级菜单 -->
                <dd><a th:href="@{/list/10/1}">Java</a></dd>
                <dd><a th:href="@{/list/11/1}">C++</a></dd>
                <dd><a th:href="@{/list/12/1}">Python</a></dd>
                <dd><a th:href="@{/list/13/1}">JavaScript</a></dd>
                <dd><a th:href="@{/list/14/1}">c语言</a></dd>
                <dd><a th:href="@{/list/15/1}">云计算</a></dd>
            </dl>
        </li>

        <li class="layui-nav-item layui-this">
            <a th:href="@{/post}">
                <i class="layui-icon layui-icon-chat"></i>
                论坛
            </a>
        </li>

        <div class="head_div1">
            <input class="head_div1_input1" placeholder="&nbsp 输 入 你 要 找 的 帖 子 话 题">
            <button class="head_div1_button">
                <i class="layui-icon layui-icon-search" style="font-size: 25px;"></i>
            </button>
        </div>

        <div class="head_div2">

            <li class="layui-nav-item">
                <a th:href="@{/friends}">
                    <i class="layui-icon layui-icon-friends"></i>
                    好友列表
                </a>
            </li>

            <li class="layui-nav-item">
                <a href=""><img th:src="${session.user.headImg}" class="layui-nav-img"><span th:text="${session.user.username}">2</span></a>
                <dl class="layui-nav-child">

                    <dd>
                        <a th:href="@{/personalInformation}">
                            <i class="layui-icon layui-icon-chat"></i>
                            个人信息
                        </a>
                    </dd>

                    <dd>
                        <a th:href="@{/outLogin(id = ${session.user.id})}">
                            <i class="layui-icon layui-icon-logout"></i>
                            退了
                        </a>
                    </dd>

                </dl>
            </li>

        </div>
    </ul>
</div>

<div class="button">
    <button type="button" class="layui-btn layui-btn-normal" id="button"><i class="layui-icon layui-icon-edit"></i>发布</button>
</div>

<div class="div_body">

<!--    <div class="div_body_div1">-->
<!--        <div class="div_body_div1_div1"><img src="../static/读书1.jpg"></div>-->
<!--        <div class="div_body_div1_div2">备战春招，面试刷题跟他复习，一个月全搞定！</div>-->
<!--        <div class="div_body_div1_div3">-->

<!--            <div class="div_body_div1_div3_div1">-->
<!--                <span class="div_body_div1_div3_div1_span1">吴志伟</span>-->
<!--                <span class="div_body_div1_div3_div1_span2">发布于</span>-->
<!--                <span class="div_body_div1_div3_div1_span3">2019-04-15 15:32:18</span>-->
<!--            </div>-->

<!--            <div class="div_body_div1_div3_div2">-->
<!--                <span class="div_body_div1_div3_div2_span1">话题类型:</span>-->
<!--                <span class="div_body_div1_div3_div2_span2">Java</span>-->
<!--            </div>-->

<!--        </div>-->
<!--    </div>-->

</div>
<!---->

<!-- 底部相同部分 -->
<div th:replace="foot::#foot"></div>

<!-- 弹出增加页面 -->
<div class="addPost" id="addPost" style="display: none;">
    <div class="addPost_div1">
        <span class="addPost_div1_span">标题</span>
        <input class="addPost_div1_input" id="title" name="title">
    </div>

    <div class="addPost_div2">
            <textarea name="content" class="addPost_div2_textarea" id="content"></textarea>
    </div>

    <div class="addPost_div3">
        <span class="addPost_div3_span">分类</span>
        <select class="addPost_div3_select" id="type" name="type">
            <option>其他</option>
            <option>Java</option>
            <option>C++</option>
            <option>Python</option>
            <option>JavaScript</option>
            <option>c语言</option>
            <option>云计算</option>
        </select>
    </div>

    <div class="addPost_div5">
        <button type="button" class="layui-btn"><i class="layui-icon layui-icon-edit"></i>发表</button>
    </div>

</div>

</body>
<!--  -->
<script th:inline="javascript">
    <!-- layui -->
    layui.use('element', function () {
        var element = layui.element;
    });

    //弹出页面
    $("#button").click(function () {
        layui.use('layer', function () {
            layer.open({
                type: 1,//1是当前页面内容，2是路径内容
                area: ["760px", "675px"],
                content: $("#addPost").html(), //当前$("#popSearchRoleTest").html()，其他页面test2.html
                title: "发表帖子"
            })
            $('.layui-layer-content .layui-btn').click(function() {
                var title = $(".layui-layer-content #title").val();
                var content = $(".layui-layer-content #content").val();
                var type = $(".layui-layer-content #type").val();
                var userId = [[${session.user.id}]];
                if(title == '' || title == null){
                    layer.msg('请输入标题!');
                    return false;
                }
                if(content == '' || content == null){
                    layer.msg('请输入内容!');
                    return false;
                }
                layui.use('layer', function() {
                    $.ajax({
                        url:'/ImagineCommunity/addPost',
                        data:{title:title,
                              content:content,
                              type:type,
                              userId:userId,
                        },//数据
                        success:function(res){
                            layer.msg('提交成功!');//弹出信息 //layer.close(layer.index);//关闭弹窗
                            setTimeout(function(){//延迟1秒再跳转
                                layer.closeAll();
                                window.location.href = "/ImagineCommunity/post";
                            }, 1000);
                        }
                    })
                })
            })
        })
    })

    <!--  -->
    layui.use(['flow','form'],function(){
        var flow=layui.flow,form=layui.form;
        $('.div_body').empty();
        flow.load ({
            elem: '.div_body', //指定列表容器
            end:"下面没有更多话题了!",
            done:function(page,next){
                var list=[];
                $.ajax({
                    url:'/ImagineCommunity/postList',
                    data:{pageNo:page},
                    success:function(res){
                        console.log(res);
                        $.each(res.page.items, function(index, item){
                            list.push(
                            "<a href='/ImagineCommunity/postDetails?id=" + item.id + "'>" +
                            "<div class='div_body_div1'>" +
                                "<div class='div_body_div1_div1'><img src=' " + item.headImg + " '></div>" +
                                "<div class='div_body_div1_div2'>" + item.title + "</div>" +
                                "<div class='div_body_div1_div3'>" +

                                    "<div class='div_body_div1_div3_div1'>" +
                                        "<span class='div_body_div1_div3_div1_span1'>" + item.userName + "</span>" +
                                        "<span class='div_body_div1_div3_div1_span2'>发布于</span>" +
                                        "<span class='div_body_div1_div3_div1_span3'>" + item.createTime + "</span>" +
                                    "</div>" +

                                    "<div class='div_body_div1_div3_div2'>" +
                                        "<span class='div_body_div1_div3_div2_span1'>话题类型:</span>" +
                                        "<span class='div_body_div1_div3_div2_span2'>" + item.type + "</span>" +
                                    "</div>" +

                                "</div>" +
                            "</div>"+
                            "</a>"
                            );
                        })
                        next(list.join(''), page < res.page.pageTotal);
                    }
                })
            }
        })
    })
    <!--  -->

    <!-- 搜索帖子 -->
    $(".head_div1_button").click(function(){
        var searchValue = ($(".head_div1_input1").val());
        layui.use(['flow','form'],function(){
            var flow=layui.flow,form=layui.form;
            $('.div_body').empty();
            flow.load ({
                elem: '.div_body', //指定列表容器
                end:"下面没有更多话题了!",
                done:function(page,next){
                    var list=[];
                    $.ajax({
                        url:'/ImagineCommunity/searchPostList',
                        data:{pageNo:page,
                              searchValue:searchValue,
                        },
                        success:function(res){
                            console.log(res);
                            $.each(res.page.items, function(index, item){
                                list.push(
                                "<a href='/ImagineCommunity/postDetails?id=" + item.id + "'>" +
                                "<div class='div_body_div1'>" +
                                    "<div class='div_body_div1_div1'><img src=' " + item.headImg + " '></div>" +
                                    "<div class='div_body_div1_div2'>" + item.title + "</div>" +
                                    "<div class='div_body_div1_div3'>" +

                                        "<div class='div_body_div1_div3_div1'>" +
                                            "<span class='div_body_div1_div3_div1_span1'>" + item.userName + "</span>" +
                                            "<span class='div_body_div1_div3_div1_span2'>发布于</span>" +
                                            "<span class='div_body_div1_div3_div1_span3'>" + item.createTime + "</span>" +
                                        "</div>" +

                                        "<div class='div_body_div1_div3_div2'>" +
                                            "<span class='div_body_div1_div3_div2_span1'>话题类型:</span>" +
                                            "<span class='div_body_div1_div3_div2_span2'>" + item.type + "</span>" +
                                        "</div>" +

                                    "</div>" +
                                "</div>"+
                                "</a>"
                                );
                            })
                            next(list.join(''), page < res.page.pageTotal);
                        }
                    })
                }
            })
        })
    })

    <!-- 浏览器关闭事件,浏览器关闭时向后台发送退出链接 -->
    $(window).unload(function(){
        $.ajax({
            url : "/ImagineCommunity/outLogin?id=[[${session.user.id}]]",
        })
    });

</script>

</html>
